<template>
  <scroll-view class="whf oh" scroll-y>
    <view class="list xw wf zb p1em">
      <view v-for="i in data.data" :key="i.id" class="w48">
        <GoodsItem :modelValue="i" class="wf" />
      </view>
    </view>
  </scroll-view>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import GoodsItem from "@/components/GoodsItem.vue";
export default defineComponent({
  name: "list",
  components: { GoodsItem },
  // props: {modelValue:{type:Object,default(){return {};}}},
  // watch:{modelValue:{handler(n,o){this.init();},deep:true}},
  data() {
    return {
      data: { current: 0, size: 10, data: [] as gt.sql.goods[] } as gt.PageData<gt.sql.goods>,
      rname: ""
    };
  },
  // computed:{},
  onLoad(p) {
    if (p) {
      if (p.name) {
        this.rname = p.name;
      }
    }
    this.init();
  },
  // onPullDownRefresh() {uni.stopPullDownRefresh();},
  methods: {
    async init() {
      const r: R<gt.sql.goods>[] = [];
      if (this.rname) {
        r.push({ field: "name", logic: "like", value: this.rname });
      }
      this.data = await gd.goods.read({ "#page": { current: this.data.current + 1, size: this.data.size }, "#order": [["createTime", "DESC"]], "#rule": r });
      console.log(this.data.data);
    },
  },
  // mounted() { },
});
</script>
<style lang="scss" scoped>
.list {
  background-color: #eee;
}
</style>